#ifndef SOFTIRQ_H_
#define SOFTIRQ_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "pt.h"
#include "ptdef.h"

#define SOFTIRQ_MAX 8
enum softirq_prio{
    HI_SOFTIRQ = 0,
    TIMER_SOFTIRQ,
    TASKLET,
};




struct softirq_action{
    void (*action)(struct softirq_action *);
    void *data;
    uint32_t len;
};

void open_softirq(int nr, void (*action)(struct softirq_action *));
int32_t raise_softirq(uint8_t softirq_num);
void do_softirq(void);
void softirt_pass_params(int nr, void *data, uint32_t len);

void set_swi_pending( void (*cpu_swi_pending)(void) );


struct tasklet_struct
{
	pt_list_t list;
	unsigned long state;
	uint32_t count;
	void (*func)(void *data, uint32_t len);
	void *data;
	uint32_t len;
};



enum
{
    TASKLET_STATE_READY = 0,
	TASKLET_STATE_SCHED,	/* Tasklet is scheduled for execution */
	TASKLET_STATE_RUN	/* Tasklet is running (SMP only) */
};

void tasklet_schedule(struct tasklet_struct *t);
void tasklet_init(struct tasklet_struct *t, void (*func)(void *data, uint32_t len));
void tasklet_pass_params(struct tasklet_struct *t, void *data, uint32_t len);
struct tasklet_struct *tasklet_create(void (*func)(void *data, uint32_t len));

#ifdef __cplusplus
}
#endif

#endif
